const path = require('path');

// 基础URL配置
const BASE_URL = process.env.BASE_URL || 'http://localhost:3001';

// 获取文件URL
const getFileUrl = (filePath) => {
  return `${BASE_URL}/${filePath}`;
};

// 获取文件存储路径
const getStoragePath = (fileType) => {
  const paths = {
    avatar: 'uploads/avatars',
    banner: 'uploads/banners',
    video: 'uploads/videos',
    image: 'uploads/images'
  };
  return paths[fileType] || 'uploads/images';
};

// 生成文件名
const generateFileName = (originalname) => {
  const timestamp = Date.now();
  const ext = path.extname(originalname);
  return `${timestamp}${ext}`;
};

module.exports = {
  getFileUrl,
  getStoragePath,
  generateFileName
}; 